package com.lovo.project2.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lovo.project2.bean.ProcuredBean;
import com.lovo.project2.mapper.IProcuredBeanMapper;
import com.lovo.project2.service.IProcuredBeanService;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
@Service
public class ProcuredBeanServiceImpl extends ServiceImpl<IProcuredBeanMapper, ProcuredBean> implements IProcuredBeanService {
    @Override
    public IPage<ProcuredBean> queryAllProcuredBean(IPage iPage, String buyer, LocalDate stateTime, LocalDate entTime) {
        QueryWrapper queryWrapper=new QueryWrapper();
        if (buyer!=null&&!"".equals(buyer)){
            queryWrapper.like("name",buyer);
        }if (stateTime!=null&&!"".equals(stateTime)){
            queryWrapper.ge("buy_time",stateTime);
        }if (entTime!=null&&!"".equals(entTime)){
            queryWrapper.le("buy_time",entTime);
        }
        return baseMapper.selectPage(iPage,queryWrapper);
    }

    @Override
    public ProcuredBean queryProcuredBeanById(int id) {

        return baseMapper.selectById(id);
    }

    @Override
    public void addProcuredBean(ProcuredBean procuredBean) {
baseMapper.insert(procuredBean);
    }
}
